import UIKit

class BaseViewController: UITableViewController, VisitorLoginViewDelegate{

    //定义用户是否登录的标示
//    var userlogin : Bool = UserAccount.loadUserAccount()?.access_token != nil 
    var userlogin : Bool = UserAccountViewModel.sharedUserAccountViewModel.userLogin
    var visitorLoginView : VisitorLoginView?
    
    override func viewDidLoad() {
        super.viewDidLoad()
    }
  
    override func loadView() {
        if userlogin {
            
            super.loadView()
            
        }else{
            
/// 如果只用一个临时变量去接的话  给主View赋值之后  就被销毁了
//            let v = VisitorLoginView()
//            view = v
            visitorLoginView = VisitorLoginView()
            visitorLoginView?.visitorLoginViewDelegate = self
            view = visitorLoginView
        }

    }
    //会在 viewwillLayoutsubViews方法中 设置view的大小
    override func viewWillLayoutSubviews() {
        super.viewWillLayoutSubviews()
//        print(view)
//        print(view.classForCoder)
    }
    
    func userWillLogin() {
        
        let OAuth = OAuthViewController()
        let navi = UINavigationController(rootViewController: OAuth)
        presentViewController(navi, animated: true, completion: nil)
        
    }
    func userWillRegister() {

    }


}
